<%--
Copyright (c) 2004-2006 BroadVision, Inc.  All rights reserved.

This software is copyrighted. Under the copyright laws, this software
may not be copied, in whole or in part, without prior written consent
of BroadVision, Inc. or its assignees. This software is provided
under the terms of a license between BroadVision and the recipient,
and its use is subject to the terms of that license.

This software may be protected by one or more U.S. and International
patents.  Certain applications of BroadVision One-To-One software are
covered by U.S. patent 5,710,887.

TRADEMARKS: BroadVision and BroadVision One-To-One are registered
trademarks of BroadVision, Inc., in the United States and the
European Community, and are trademarks of BroadVision, Inc., in other
countries.  The BroadVision logo, is a trademark of BroadVision,
Inc., in the United States and other countries. Additionally, IONA
and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and
RC2 are trademarks of RSA Data Security, Inc.

--%><%@ taglib uri="/WEB-INF/c.tld" prefix="c"
%><%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el"
%><%@ page import="java.util.List"
%><%@ page import="java.util.ArrayList"
%><%@ page import="com.broadvision.web.servlet.SessionMenu"
%><%@ page import="com.broadvision.web.action.Menu"
%><%

  String ctxPath = request.getContextPath();
  SessionMenu sessionMenu = SessionMenu.getInstance(request.getSession());
  Menu menu = sessionMenu.getVisitorMenu().getMenu();
  List items = (null == menu) ? new ArrayList() : menu.getItems();
  pageContext.setAttribute("items", items);

%><table cellspacing="0" cellpadding="0" border="0" width="100%" summary="menu">

<c:set var="expandImg">
   <img src="<%= ctxPath %>/mc/images/menu/menu_expand.gif" width="10" height="17" alt="<bean-el:message key="image.alt.collapse" bundle="mc.messages"/>" title="<bean-el:message key="image.alt.collapse" bundle="mc.messages"/>" border="0" name="<bean-el:message key="image.alt.collapse" bundle="mc.messages"/>" style="vertical-align: middle;">
</c:set><c:set var="collapseImg">
   <img src="<%= ctxPath %>/mc/images/menu/menu_collapse.gif" width="10" height="17" alt="<bean-el:message key="image.alt.expand" bundle="mc.messages"/>" title="<bean-el:message key="image.alt.expand" bundle="mc.messages"/>" border="0" name="<bean-el:message key="image.alt.expand" bundle="mc.messages"/>" style="vertical-align: middle;">
</c:set><c:set var="selectImg">
   <img src="<%= ctxPath %>/mc/images/menu/menu_select.gif" width="13" height="10" alt="<bean-el:message key="image.alt.selected" bundle="mc.messages"/>" title="<bean-el:message key="image.alt.selected" bundle="mc.messages"/>" border="0" name="<bean-el:message key="image.alt.selected" bundle="mc.messages"/>" style="vertical-align: middle;">
</c:set>
<c:set var="itemVisible" value="0"/>

<c:forEach var="item" items="${items}">
  <c:if test="${item.visible}">

  <c:set var="itemVisible" value="1"/>

  <c:choose>
    <c:when test="${item.level > 1}">
      <c:set var="stylePrefix" value="submenu"/>
    </c:when>
    <c:otherwise>
      <c:set var="stylePrefix" value="menu"/>
    </c:otherwise>
  </c:choose>

  <c:choose>
    <c:when test="${item.selected && empty item.children}">
      <c:set var="style" value="${stylePrefix}On"/>
    </c:when>
    <c:otherwise>
      <c:set var="style" value="${stylePrefix}Off"/>
    </c:otherwise>
  </c:choose>

  <c:url var="expandUrl" value="${item.path}.do">
    <c:param name="expand" value="${item.id}"/>
  </c:url>
  <c:url var="collapseUrl" value="${item.path}.do">
    <c:param name="expand" value="-${item.id}"/>
  </c:url>
  <c:url var="itemUrl" value="${item.path}.do"/>

  <tr>
    <td class="<c:out value="${style}"/>" width="10%">
  <c:choose>
    <c:when test="${item.expanded}">
      <a href="<c:out value="${collapseUrl}"/>"><c:out value='${expandImg}' escapeXml="false"/></a>
    </c:when>
    <c:when test="${!empty item.children}">
      <a href="<c:out value="${expandUrl}"/>"><c:out value='${collapseImg}' escapeXml="false"/></a>
    </c:when>
    <c:otherwise>
      &nbsp;
    </c:otherwise>
  </c:choose>
    </td>
    <td class="<c:out value="${style}"/>" width="80%">
  <c:choose>
    <c:when test="${empty item.path}">
      <c:if test="${empty item.onclick}">
        <c:out value="${item.name}"/>
      </c:if>
      <c:if test="${not empty item.onclick}">
      <a href="#" onclick="<c:out value="${item.onclick}"/>"><c:out value="${item.name}"/></a>
      </c:if>
    </c:when>
    <c:otherwise>
      <c:if test="${empty item.onclick}">
      <a href="<c:out value="${itemUrl}"/>"><c:out value="${item.name}"/></a>
      </c:if>
      <c:if test="${not empty item.onclick}">
      <a href="<c:out value="${itemUrl}"/>" onclick="<c:out value="${item.onclick}"/>"><c:out value="${item.name}"/></a>
      </c:if>
    </c:otherwise>
  </c:choose>
    </td>
    <td class="<c:out value="${style}"/>" width="10%">
  <c:choose>
    <c:when test="${item.selected && empty item.children}">
      <c:out value='${selectImg}' escapeXml="false"/>
    </c:when>
    <c:otherwise>
      &nbsp;
    </c:otherwise>
  </c:choose>
    </td>
  </tr>
  </c:if>
</c:forEach>

<c:if test="${!empty items && itemVisible == 1}">
   <tr class="menuFooterImage">
      <td colspan="3" align="right"><img src="<%=ctxPath%>/mc/images/menu/bot-right-footer.gif" width="6" height="5" alt=""></td>
   </tr>
</c:if>

</table>

<c:if test="${!empty items && itemVisible == 1}"><div class="menuFooter"></div></c:if>